home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / zip.h < prev   
C/C++ Source or Header  |  2000-01-16  |  2KB  |  99 lines

  1. // $Id: zip.h,v 1.5 1999/07/06 14:00:40 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef zip_INCLUDED
  11. #define zip_INCLUDED
  12.  
  13. #ifdef WIN32_FILE_SYSTEM
  14. #include <windows.h>
  15. #endif
  16.  
  17. #include "config.h"
  18. #include <stddef.h>
  19. #include <stdio.h>
  20. #include "tuple.h"
  21. #include "unzip.h"
  22.  
  23. class Control;
  24. class Zip;
  25. class DirectorySymbol;
  26. class FileSymbol;
  27.  
  28.  
  29. class ZipFile : public Unzip
  30. {
  31. public:
  32.  
  33.     ZipFile(FileSymbol *);
  34.     ~ZipFile();
  35.  
  36. private:
  37.     char *buffer;
  38.  
  39.     u1 GetU1();
  40.     u2 GetU2();
  41.     u4 GetU4();
  42.     void Skip(u4 length);
  43.  
  44. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  45.         FILE *zipfile;
  46.         static int (*uncompress_file[10]) (FILE *, char *, long);
  47.     public:
  48.         inline char *Buffer() { return buffer; }
  49. #elif defined(WIN32_FILE_SYSTEM)
  50.         char *file_buffer;
  51.         static int (*uncompress_file[10]) (char *, char *, long);
  52.     public:
  53.         inline char *Buffer() { return (buffer ? buffer : file_buffer); }
  54. #endif
  55. };
  56.  
  57.  
  58. class Zip
  59. {
  60. public:
  61.     Zip(Control &, char *);
  62.     ~Zip();
  63.  
  64.     bool IsValid() { return magic == 0x06054b50; }
  65.  
  66.     DirectorySymbol *RootDirectory() { return root_directory; }
  67.  
  68. private:
  69.     friend class ZipFile;
  70.  
  71.     Control &control;
  72.  
  73.     u4 magic;
  74.  
  75.     DirectorySymbol *root_directory;
  76.  
  77.     char *zipbuffer,
  78.          *buffer_ptr;
  79.  
  80.     u1 GetU1();
  81.     u2 GetU2();
  82.     u4 GetU4();
  83.     void Skip(u4 length);
  84.  
  85.     void ReadDirectory();
  86.  
  87.     NameSymbol *ProcessFilename(char *, int);
  88.     DirectorySymbol *ProcessSubdirectoryEntries(DirectorySymbol *, char *, int);
  89.     void ProcessDirectoryEntry();
  90.  
  91. #if defined(UNIX_FILE_SYSTEM) || defined(AMIGAOS_FILE_SYSTEM)
  92.     FILE *zipfile;
  93. #elif defined(WIN32_FILE_SYSTEM)
  94.     HANDLE zipfile, mapfile;
  95. #endif
  96. };
  97. #endif /* zip_INCLUDED */
  98.  
  99.